import React, {useEffect, useState} from 'react';
import {
  ScrollView,
  View,
  Text,
  TouchableOpacity,
  ActivityIndicator,
  FlatList,
  Image,
  TextInput,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import AreaView from '../../components/Layout/AreaView';
import {getNewList} from '../../service/my';
import BaseUrl from '../../config/BaseUrl';
import styles from './style';

const DiscountCoupon = () => {
  const navigation = useNavigation();
  const [pn, setPn] = useState(1);
  const [list, setList] = useState([]);
  useEffect(() => {
    getNewList({pn}).then((res) => {
      console.log(res);
      setList(res.rows);
    });
  }, [pn]);
  return (
    <AreaView>
      <ScrollView style={styles.container}>
        {(list || []).map((item) => (
          <View key={item.newsId} style={styles.list}>
            <Image
              source={{uri: BaseUrl.imgurl + item.newsImage}}
              style={styles.cover}
            />
            <Text style={styles.desc}>{item.newsContent}</Text>
          </View>
        ))}
      </ScrollView>
    </AreaView>
  );
};

export default DiscountCoupon;
